package com.example.trackcircuitdiagnosis.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.trackcircuitdiagnosis.entity.FaultTypeEntity;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author 23639
* @description 针对表【fault_type】的数据库操作Mapper
* @createDate 2024-04-23 21:01:14
* @Entity com/example/trackcircuitdiagnosis/entity.domain.FaultType
*/
public interface FaultTypeMapper extends BaseMapper<FaultTypeEntity> {

    @Select("select a.*,b.`name` as facilityName,c.`name` as areaTypeName " +
            "from fault_type a " +
            "LEFT JOIN facility_type b on a.facilityId=b.id " +
            "LEFT JOIN area_type c on b.areaTypeId=c.id " +
            "where a.id = #{id}")
    FaultTypeEntity selectById(Integer id);

    @Select("select ft.*, fyt.name as facilityName, at.id as areaTypeId,at.name as areaTypeName, tcm.id as modelId, tcm.name as modelName " +
            "from fault_type ft left join facility_type fyt on ft.facilityId = fyt.id " +
            "left join area_type at on fyt.areaTypeId = at.id " +
            "left join track_circuit_model tcm on tcm.id = at.modelId;")
    List<FaultTypeEntity> selectAll();

}




